<include file="Layout/header" />
<link rel="stylesheet" href="__PUBLIC__/App/css/trade.css">

    <div class="inner-page-nav-wrap">
        <ul class="inner-page-nav clearfix">
            <li id="JS-apply-operate" class="JS-dotrade nav active"><a href="http://www.gubao668.com/trade/dayTrade.html">申请配资资金</a></li>
            
        </ul>
    </div>
    <div class="inner-content-wrap-trade">
        <div class="trade-nav-warp clearfix">
            <div>0</div>
            <a id="JS-day" href="http://www.gubao668.com/trade/dayTrade.html" class="t-navtext selected">按天配资</a>
            <a id="JS-month" href="http://www.gubao668.com/trade/monthTrade.html" class="t-navtext">按月配资</a>
            
            
            
            <div id="JS-limit-stock" class="t-daylimit" onclick="buylimit()">今日限买股</div>
        </div>
        <div class="trade-content-wrap clearfix">
            <div class="trade-form clearfix">
                <div class="select-btn-label">投入资金</div>
                <div class="select-btn-group-wrap">
                    <button id="JS-5000" data-pzamount="200" class="JS-trade-applyAmount select-btn select-btn-active">200</button>
                    <button id="JS-10000" data-pzamount="500" class="JS-trade-applyAmount select-btn">500</button>
                    <button id="JS-30000" data-pzamount="1000" class="JS-trade-applyAmount select-btn">1000</button>
                    <button id="JS-100000" data-pzamount="5000" class="JS-trade-applyAmount select-btn">5000</button>
                    <button id="JS-150000" data-pzamount="10000" class="JS-trade-applyAmount select-btn">1万</button>
                    <button id="JS-200000" data-pzamount="50000" class="JS-trade-applyAmount select-btn">5万</button>
                    <button id="JS-300000" data-pzamount="100000" class="JS-trade-applyAmount select-btn">10万</button>
                    <button id="JS-otherApplyAmount" data-pzamount="otherApplyAmount" class="JS-trade-applyAmount select-btn">其他金额</button>

                    <input id="JS-input-amount" placeholder="最少2百，最多500万，百的整数倍" style="width: 447px; display: none;" class="JS-other-input" onkeyup="inputaplmochange(this)" type="text">
                    <span id="errInputTip" style="display: none" class="select-input-error"><i class="icon-jinggao"></i><i id="errow_title">最少2百，最多500万，百的整数倍</i></span>

                    <input id="moneymin" value="200" type="hidden">
                    <input id="moneymax" value="5000000" type="hidden">
                    <input id="available_balance_money" value="0" type="hidden">
                    <input id="productid" value="71" type="hidden">


                </div>
                <div class="select-btn-label">申请配资资金</div>

                <div class="select-btn-group-wrap last-child"> <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn select-btn-active"><div data-mutiple="3">3倍</div><div class="monthinterest"></div><div class="JS-invest-val">600 元</div></div> <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn "><div data-mutiple="4">4倍</div><div class="monthinterest"></div><div class="JS-invest-val">800 元</div></div> <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn "><div data-mutiple="5">5倍</div><div class="monthinterest"></div><div class="JS-invest-val">1000 元</div></div> <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn "><div data-mutiple="6">6倍</div><div class="monthinterest"></div><div class="JS-invest-val">1200 元</div></div> <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn "><div data-mutiple="7">7倍</div><div class="monthinterest"></div><div class="JS-invest-val">1400 元</div></div> <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn "><div data-mutiple="8">8倍</div><div class="monthinterest"></div><div class="JS-invest-val">1600 元</div></div> <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn "><div data-mutiple="9">9倍</div><div class="monthinterest"></div><div class="JS-invest-val">1800 元</div></div> <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn "><div data-mutiple="10">10倍</div><div class="monthinterest"></div><div class="JS-invest-val">2000 元</div></div></div>

            </div>
            <div class="JS-result trade-result">
                <div class="trade-res">
                    <table>
                        <tbody><tr>
                            <td class="first-column">总配资资金</td>
                            <td><span class="font-color-dark font-bold" id="totalMoney">800.00</span>&nbsp;&nbsp;元<span class="tips">（申请资金&nbsp;+&nbsp;投资本金）</span></td>
                        </tr>
                        <tr>
                            <td class="first-column">单票持仓</td>
                            <td><span>主板100%，创业板100%</span></td>
                        </tr>
                        <tr class="line">
                            <td class="first-column">持仓时间</td>
                            <td id="monthtimetip">自动延期</td>
                        </tr>
                        <tr>
                            <td class="first-column">警戒线</td>
                            <td><span class="font-color-orangr" id="rateWarn">700.02</span>&nbsp;&nbsp;元<span class="tips">（冻结买入）</span></td>
                        </tr>
                        <tr>
                            <td class="first-column">止损线</td>
                            <td><span class="font-color-green" id="rateOpenLine">660.00</span>&nbsp;&nbsp;元</td>
                        </tr>
                        <tr>
                            <td class="first-column">投资本金</td>
                            <td><span class="JS-capitalAmount" id="benjin">200</span>&nbsp;&nbsp;元</td>
                        </tr>
                        <tr>
                            <td class="first-column">管理费</td>
                            <td style="position: relative;" class="clearfix">
                                <span class="JS-trade-mgamt" id="fee">1.08</span>&nbsp;元 <span>x 2天</span><span>（非交易日不收取）</span><span class="tehui-qg-tips"></span>
                                
                            </td>
                        </tr>
                        <tr class="line">
                            <td class="first-column">利益分配</td>
                            <td><span class="font-color-red font-bold" id="profit_distribution">盈利全归您</span></td>
                        </tr>
                        <tr>
                            <td class="font-bold first-column">共计应支付</td>
                            <td><span class="JS-payall font-color-red font-bold font-size-16" id="paymoney">202.16</span>&nbsp;&nbsp;元<span class="tips">（准备资金 = 投资本金 + 日管理费 x 天数） </span></td>
                        </tr>
                        
                    </tbody></table>
                </div>
            </div>
        </div>
        <div class="form-submit-btn">
            <p>
                <span class="tips">申请即表示已阅读并同意</span><a id="JS-tradeProtocol" href="javascript:void(0)" onclick="protocolTrade()">《股宝网配资协议》</a>
                <button id="JS-instant-apply" class="JS-trade-deal btn-standard btn-blue" onclick="startstock()">立即申请</button>
            </p>

        </div>
    </div>

<script src="__PUBLIC__/App/js/product.js"></script>
<script type="text/javascript">
    $(function () {
        //初始化产品
        $(function () {
            innitDayProduct(1);
            benjinchange();
            quanmoney = 0;
            monthmin = 2;
            monthmax = 2;
            coupid = 0;
        });
    });
    var productid = 0;
    var totalMoney = 0;
    var rateWarn = 0;
    var rateOpenLine = 0;
    var fee = 0;
    var feemoney = 0;
    var borrowmoney = 0;
    var profit_distribution = 0;
    var managerfee = 0;
    function checkmoney() {
        money = $(".select-btn-active").attr("data-pzamount");
        var moneyTime = 0;
        $(".JS-trade-investAmount").each(function (apply_money) {
            $this = $(this);
            if ($(this).hasClass("select-btn-active")) {
                moneyTime = $(this).children(":first").attr("data-mutiple");
                // var rate = $(this).siblings().eq(1).text().substring(0, $(this).siblings().eq(1).text().length - 1);
                //$(this).text(Math.round(parseInt(apply_money) * parseInt(mulip)) + "元");

            }
        });
        
        if (money != "" && money != 0) {
            for (var i = 0; i < productsDay.length; i++) {
                if (productsDay[i].moneyMin <= money && money < productsDay[i].moneyMax) {

                    if (productsDay[i].moneyTimes == moneyTime) {
                        productid = productsDay[i].id;
                        totalMoney = ((productsDay[i].moneyTimes * money) + parseFloat(money)).toFixed(2);
                        feemoney = (productsDay[i].moneyRate * (productsDay[i].moneyTimes * money)).toFixed(2);
                        rateWarn = (productsDay[i].moneyTimes * money * productsDay[i]["rateWarn"]).toFixed(2);
                        rateOpenLine = (productsDay[i].moneyTimes * money * productsDay[i]["rateOpenLine"]).toFixed(2);
                        fee = (100 * productsDay[i].moneyRate).toFixed(2);
                        managerfee = (feemoney * productsDay[i].monthMin).toFixed(2);
                        monthmin = productsDay[i].monthMin;
                        monthmax = productsDay[i].monthMax;
                        borrowmoney = (productsDay[i].moneyTimes * money).toFixed(2);
                        profit_distribution = parseInt(productsDay[i].profit_distribution);

                       // $("#monthtimetip").text("自动延期，最短" + productsDay[i].monthMin + "个交易日,最长" + productsDay[i].monthMax + "个交易日");

                        $("#monthtimetip").text("自动延期");

                        $("#productid").val(productsDay[i].id);
                    }

                }
            }
        }
        if (profit_distribution == 10 || profit_distribution == "10") {
            $("#profit_distribution").text("盈利全归您");
        } else {
            $("#profit_distribution").text("盈利" + profit_distribution + "成归您");

        }

        $("#productId").val(productid);
        $("#totalMoney").html(fMoney(totalMoney, 2));
        $("#rateWarn").html(fMoney(rateWarn, 2));
        $("#rateOpenLine").html(fMoney(rateOpenLine, 2));
        $("#fee").html(feemoney);

        $("#benjin").text(money);

        if ((managerfee - quanmoney).toFixed(2) < 0) {
            $("#getcoup").text("0");
            //$("#paymoney").text(parseFloat(money));

        } else {
            $("#getcoup").text(Math.ceil(managerfee) - parseInt(quanmoney));
            //$("#paymoney").text((parseFloat(managerfee) + parseFloat(money) - parseFloat(quanmoney)).toFixed(2));
        }
        $("#paymoney").text((parseFloat(managerfee) + parseFloat(money)).toFixed(2));
    }

    function benjinchange() {
        //投入本金切换
        $(".JS-trade-applyAmount").each(function () {
            $this = $(this);
            $this.bind("click", function () {
                if (!$(this).hasClass("select-btn-active")) {
                    $(this).addClass("select-btn-active");
                    $(this).siblings(".JS-trade-applyAmount").removeClass("select-btn-active");

                    $(".last-child").show();
                    if ($(this).index() == 7) {
                        $("#JS-input-amount").show();
                        $(".last-child").hide();
                        // $("#errInputTip").show();
                    } else {
                        $("#JS-input-amount").hide();
                        benjin_money();

                        checkmoney();
                    }

                }

            });
        });

    }

    function multipchange() {
        //申请资金切换
        $(".JS-trade-investAmount").each(function (apply_money) {
            $this = $(this);
            $this.bind("click", function () {
                if (!$(this).hasClass("select-btn-active")) {
                    $(this).addClass("select-btn-active");
                    $(this).siblings(".JS-trade-investAmount").removeClass("select-btn-active");
                    checkmoney();
                }
            });
        });
    }

    // 自定义本金
    function inputaplmochange(_this) {
        var value = $(_this).val();
        var moneymin = $("#moneymin").val();
        var moneymax = $("#moneymax").val();

        if (value == "") {
            return;
        }
        if (parseInt(value) % parseInt(100) != 0 || parseInt(value) < parseInt(moneymin) || parseInt(value) > parseInt(moneymax)) {
            $("#errInputTip").show();
            $(".last-child").hide();
        } else {
            $("#errInputTip").hide();
            $(".last-child").show();
            $("#JS-otherApplyAmount").attr('data-pzamount', value);

            benjin_money();
        }
    }


    var benjin_money = function () {

        var apply_money = $(".select-btn-active").attr("data-pzamount");

        //申请资金
        $(".JS-invest-val").each(function () {
            var mulip = $(this).siblings().eq(0).text().substring(0, $(this).siblings().eq(0).text().length - 1);
            var rate = $(this).siblings().eq(1).text().substring(0, $(this).siblings().eq(1).text().length - 1);
            $(this).text((apply_money * mulip).toFixed(0) + "元");
        });

        checkmoney();
    }
    isbind = 0;
    function showcoup(_this, coupsid) {

        $("#" + coupsid).toggle();

        if ($(_this).find("i").hasClass("icon-moreunfold")) {
            $(_this).find("i").removeClass("icon-moreunfold");
            $(_this).find("i").addClass("icon-less");
        } else {
            $(_this).find("i").removeClass("icon-less");
            $(_this).find("i").addClass("icon-moreunfold");
        }

        //my-coupon-list

        if (isbind == 0) {
            $(".my-coupon-list li").each(function () {
                $this = $(this);
                $this.bind("click", function () {
                    if ($(this).find("img").is(':visible')) {
                        $(this).find("img").hide();
                        quanmoney = 0;
                        coupid = 0;
                    } else {
                        $(this).siblings().find("img").hide();
                        $(this).find("img").show();
                        quanmoney = $(this).find(".num-money").text();
                        coupid = $(this).find(".coupid").text();
                    }
                    checkmoney();

                    setTimeout(function () {
                        $("#" + coupsid).hide();
                        return;
                    }, 500);

                });

            });
            isbind = 1;
        }

    }
</script>    

<include file="Layout/footer" />